import {
    reqGetSearchList
} from "@/api"
const state = {
    searchList: {}
};
const mutations = {
    GETSEARCHLIST(state, searchList) {
        state.searchList = searchList
    }
};
const actions = {
    async getSearchList({
        commit
    }, params) {
        let result = await reqGetSearchList(params)
        // console.log(result)
        commit('GETSEARCHLIST', result.data)
    }
};
//计算属性，在项目中为简化数据而生
// 可以把将来组件中需要的数据简化一下
const getters = {
    // 这里可能出现一个问题：当state中服务器的数据还没有返回时，这里会返回一个undefined，所以应该至少让它返回一个空数组
    goodsList(state) {
        return state.searchList.goodsList || []
    },
    attrsList(state) {
        return state.searchList.attrsList || []
    },
    trademarkList(state) {
        return state.searchList.trademarkList || []
    }
}

export default {
    state,
    mutations,
    actions,
    getters
}